<template>
	<view class="mainbgc mainpadding">
		<view class="mainpadding ffffff radius flexbetween">
			<view class="titletext">快递公司</view>
			<view class="flexright">
				<view class="margin_right" @click="show = true">
					<input type="text" class="textright" placeholder="请选择快递公司" disabled="" v-model="kuaidi">
				</view>
				<view class="right_icon"></view>
			</view>
		</view>
		<view class="mainpadding ffffff radius flexbetween margin_top">
			<view class="titletext">快递公司</view>
			<view class="flexright">
				<input class="textright" type="text" placeholder="请输入快递单号" v-model="express_no">
			</view>
		</view>
		<!-- 固定底部 -->
		<view class="gudingdb" @click="submit">
			<view class="bottombtn">提交</view>
		</view>
		<u-picker title="选择快递公司" :show="show" :columns="columns" keyName="name" @cancel="show=false" @confirm="confirm"></u-picker>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				show: false,
				columns: [],
				kuaidid:"",
				kuaidi:"",
				listid:"",
				express_no:""
			}
		},
		onLoad(options) {
			let data = JSON.parse(decodeURIComponent(options.msg));
			this.listid = data.id
			this.columns.push(data.kuaidi)
		},
		methods: {
			submit(){
				if (this.kuaidi == "") {
					httpRequest.toast("请选择物流公司")
					return
				}
				if (this.express_no == "") {
					httpRequest.toast("请填写物流单号")
					return
				}
				uni.showLoading({
					title: '请稍候...',
					mask: true
				})
				httpRequest.request('/api/order/toExpress', 'POST', {
					id:this.listid,
					express_name:this.kuaidi,
					express_no:this.express_no
				}, false, false, true).then(res => {
					uni.hideLoading()
					httpRequest.toast(res.msg)
					if (res.code == 1) {
						setTimeout(()=>{
							uni.navigateBack(1)
						},1000)
					}
				}).catch(err => {
					uni.hideLoading()
					httpRequest.toast(err.msg);
				})
			},
			confirm(e){
				this.kuaidid = e.value[0].id
				this.kuaidi = e.value[0].name
				this.show = false
			}
		}
	}
</script>

<style lang="scss" scoped>
	.huisetext {
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #999999;
	}
</style>
